#pragma once
#include <fcntl.h>

enum Error
{
    Listensock_Error,
    Bind_Error,
    Listen_Error,
    EpollCreate_Error,
};

// void SetNonBlock(int fd)
// {
//     int fl = fcntl(fd, F_GETFD);
//     if(fl == -1)
//     {
//         std::cout << errno << ": " << strerror(errno) << std::endl;
//     }

//     int ret = fcntl(fd, F_SETFL, fl | O_NONBLOCK);
// }


void SetNonBlock(int fd)
{
    int fl = fcntl(fd, F_GETFL);
    if(fl < 0)
    {
        std::cout << "get fl failed" << std::endl;
        return;
    }


    int n = fcntl(fd, F_SETFL, fl | O_NONBLOCK);
    if(n < 0)
    {
        std::cout << "set fl faild" << std::endl;
        return;
    }
}


const int window_width = 960;
const int window_height = 640;
const int block_size = 20;

const int player_speed = 3;

const double g_pi = 3.1415;
const int g_sword_width = 20;
const int g_sword_height = 40;
const int g_radius = 10;

struct Point
{
	double _x, _y;
};

struct Rect
{
	double x, y;
	double width, height;
};